<!--
 * @Author: krsea 965837746@qq.com
 * @Date: 2025-03-10 09:26:18
 * @LastEditors: krsea 965837746@qq.com
 * @LastEditTime: 2025-03-10 09:37:18
 * @FilePath: \vue3-code\2305\week4\2.组件通信（内容分发）.html
 * @Description: 
 * 
 * Copyright (c) 2025 by ${git_name_email}, All Rights Reserved. 
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件通信（内容分发）</title>
    <!-- 引入 vue.js -->
     <script src="../js/vue.js"></script>
</head>
<body>
    <!-- div id 为 app 挂载点 -->
     <div id="app">
        <h1>我是父组件的标题</h1>
        <my-component>
            <p>初始内容1</p>
			<p>初始内容2</p>
        </my-component>
     </div>
    
     <template id="temp">
		<div>
			<h2>我是子组件的标题</h2>
			<slot>
				<p>如果父组件没用插入内容,我将作为默认出现</p>
			</slot>
		</div>
	</template>
     <!-- 使用 javascript 脚本 -->
      <script type="text/javascript">
        Vue.component('my-component', {
			template: '#temp',
		})
		new Vue({
			el: '#app'
		})
      </script>
</body>
</html>